from sqlalchemy import Column, Integer, ForeignKey, UniqueConstraint
from sqlalchemy.orm import relationship

from app.db.base import Base

class Like(Base):
    __tablename__ = "likes"

    id = Column(Integer, primary_key=True, index=True)
    user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
    job_id = Column(Integer, ForeignKey("generation_jobs.id"), nullable=False)

    user = relationship("User")
    job = relationship("GenerationJob")

    __table_args__ = (UniqueConstraint('user_id', 'job_id', name='_user_job_uc'),)
